export enum ModelType {
  LLM = 'llm', // 语言模型
  FUNCCALL = 'funcCall', // 工具调用模型
  RERANK = 'rerank', // 重排模型
  EMBEDDING = 'embedding', // 索引模型
  NON = 'non', //非默认模型,
  TT = 'tt', //语音模型
}

export type ModelTypeValue = 'llm' | 'funcCall' | 'rerank' | 'embedding' | 'non' | 'tt';

export interface GetModelListModels {
  id: string;
  name: string;
  function: string;
  usedInToolCall: boolean;
  reasoning: boolean;
  maxContext: number;
  maxResponse: number;
  provider: string;
  isActive: boolean;
  defaultType: ModelTypeValue;
  api_key: string;
  base_url: string;
  isCustom: false;
  isLocal: false;
  modelType: string;
  isRecommend: boolean;
  usedCount: number;
  metadata: GetModelListMetadata;
  isConnect: boolean;
}

export interface GetModelListRes {
  total: number;
  list: GetModelListModels[];
  offset: number;
  page_size: number;
}

export interface GetModelListMetadata {
  model: string;
  name: string;
  maxContext: number;
  maxResponse: number;
  quoteMaxToken: number;
  maxTemperature: number;
  vision: boolean;
  toolChoice: boolean;
  functionCall: boolean;
  defaultSystemChatPrompt: string;
  datasetProcess: boolean;
  usedInClassify: boolean;
  customCQPrompt: string;
  usedInExtractFields: boolean;
  usedInQueryExtension: boolean;
  customExtractPrompt: string;
  usedInToolCall: boolean;
  defaultConfig: {};
  fieldMap: {};
  type: string;
  showTopP: boolean;
  showStopSign: boolean;
  responseFormatList: string[];
  provider: string;
  avatar: string;
  isCustom: boolean;
  isLocal: boolean;
  isRecommend: boolean;
  reasoning?: boolean;
  isActive?: boolean;
  onlyThinkMode?: boolean;
}

export interface GetModelListReq {
  // default?: ModelTypeValue;
  // provider?: string;
  contextLenRange?: number[][];
  modelType?: ModelTypeValue[];
  provider?: string[];
  offset?: number;
  page?: number;
  pageSize?: number;
  searchText?: string;
  isActive?: boolean;
  enableReasoning?: boolean;
}

export interface UpdateModelRes {
  isActive: boolean;
  // default: ModelTypeValue;
  default: string;
}

export interface UpdateModelReq {}

export interface PagedDataRes {
  offset?: number;
  page: number;
  pageSize: number;
  searchText?: string;
}

export interface PagedDataReq {
  total: number;
  offset: number;
  pageSize: number;
}

export interface GetProviderListRes extends PagedDataRes {
  includeLocal?: boolean;
}

export interface GetProviderListItem {
  name: string;
  avatar: string;
  description: string;
  isLocal: boolean;
  // 是否为第三方模型
  isThirdParty?: boolean;
}

export interface GetProviderListReq extends PagedDataRes {
  list: GetProviderListItem[];
}

export interface GetCreatedListRes extends PagedDataRes {}

export interface GetCreatedListItem {
  id: string;
  name: string;
  avatar: string;
  isLocal: boolean;
  status: string;
  base_url: string;
  key: string;
  // 是否为第三方模型
  isThirdParty?: boolean;
}

export interface GetCreatedListReq extends PagedDataReq {
  list: GetCreatedListItem[];
}

export interface CreateProviderReq {
  name: string;
  key: string;
  address: string;
  models?: string[];
  activateModels: string[];
}

export interface CreateProviderRes {}

export interface CreateProviderModelReq {
  providerId: string;
  providerName: string;
  // provider: string;
  name: string;
  modelType: string;
  maxContext: number;
  maxResponse: number;
  usedInToolCall: boolean;
}

export interface DeleteProviderModelReq {
  providerId: string;
  providerName: string;
  name: string;
  // provider: string;
  // model: string;
}

export interface TestModelReq {
  result: boolean;
  duration: number;
  error: string;
  message: string;
}

export interface BatchTestRes {
  modelList: string[];
}

export interface GetDefaultListItem {
  id: string;
  isConnect: boolean;
  model: string;
}

export interface GetDefaultListRes {
  chat: null | GetDefaultListItem;
  embedding: null | GetDefaultListItem;
  funcCall: null | GetDefaultListItem;
  rerank: null | GetDefaultListItem;
}

export interface BatchTestReq {}

export interface GetDefaultListConfigList {
  appId: string;
  name: string;
  shareId: string;
}

export interface GetDefaultListConfig {
  model: string;
  list: GetDefaultListConfigList[];
}

export interface GetConnectionReq {
  default: string[];
  config: GetDefaultListConfig[];
}

export interface UpdateActiveReq {
  isActive: boolean;
  key?: string;
  url?: string;
}

export interface CreateCustomModels {
  modelType: string;
  name: string;
  maxContext: number;
  maxResponse: number;
  usedInToolCall: boolean;
  enableReasoning: boolean;
  isActive: boolean;
}
export interface CreateCustomReq {
  name: string;
  key: string;
  address: string;
  models: CreateCustomModels[];
}

export interface CustomTestReq {
  key: string;
  address: string;
  name: string;
  modelType: string;
}
